﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QiHe
{
    public partial class Set_PM_Dept : Form
    {
        DataSet UnPM_DeptList;
        DataSet PM_DeptList;
        public Set_PM_Dept()
        {
            InitializeComponent();
        }

        private void Set_PM_Dept_Load(object sender, EventArgs e)
        {
            LoadData();
            skinComboBox1.SelectedIndex = 0;
       
        }


        public void LoadData()
        {

            MedEQ.Service1 sop = new MedEQ.Service1();
            UnPM_DeptList = sop.HSP_Department_PM_List_Win(DataTemp.HSPID, "0");

            skinDataGridView2.DataSource = UnPM_DeptList.Tables[0];
            for (int i = 0; i < this.skinDataGridView2.Columns.Count; i++)
            {
                this.skinDataGridView2.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
            }
        
        
        }

        private void skinDataGridView1_ChangeUICues(object sender, UICuesEventArgs e)
        {

        }

        private void skinComboBox1_MouseClick(object sender, MouseEventArgs e)
        {
          
        }

        private void skinComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            MedEQ.Service1 sop = new MedEQ.Service1();
            PM_DeptList = sop.HSP_Department_PM_List_Win(DataTemp.HSPID, (skinComboBox1.SelectedIndex + 1).ToString());

            skinDataGridView1.DataSource = PM_DeptList.Tables[0];

            for (int i = 0; i < this.skinDataGridView1.Columns.Count; i++)
            {
                this.skinDataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
            }
        }

        private void skinButton1_Click(object sender, EventArgs e)
        {
            MedEQ.Service1 sop = new MedEQ.Service1();
            sop.Update_Depts_PM_Win(UnPM_DeptList.Tables[0].Rows[skinDataGridView2.CurrentCell.RowIndex][1].ToString(), (skinComboBox1.SelectedIndex + 1).ToString());


            LoadData();

            MedEQ.Service1 sop2 = new MedEQ.Service1();
            PM_DeptList = sop2.HSP_Department_PM_List_Win(DataTemp.HSPID, (skinComboBox1.SelectedIndex + 1).ToString());

            skinDataGridView1.DataSource = PM_DeptList.Tables[0];


            for (int i = 0; i < this.skinDataGridView1.Columns.Count; i++)
            {
                this.skinDataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
            }
        }

        private void skinButton2_Click(object sender, EventArgs e)
        {
            MedEQ.Service1 sop = new MedEQ.Service1();
            sop.Update_Depts_PM_Win(PM_DeptList.Tables[0].Rows[skinDataGridView1.CurrentCell.RowIndex][1].ToString(),"0");


            LoadData();

            MedEQ.Service1 sop2 = new MedEQ.Service1();
            PM_DeptList = sop2.HSP_Department_PM_List_Win(DataTemp.HSPID, (skinComboBox1.SelectedIndex + 1).ToString());

            skinDataGridView1.DataSource = PM_DeptList.Tables[0];

            for (int i = 0; i < this.skinDataGridView1.Columns.Count; i++)
            {
                this.skinDataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
            }
        }
    }
}
